package com.qianfeng.controller;

import com.qianfeng.entity.Patient;
import com.qianfeng.service.PatientService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/admin")
public class ManageController {

    @Autowired
    PatientService patientService;

    static Logger logger = LoggerFactory.getLogger(ManageController.class);

    @PostMapping("/addPatient")
    public String addPatient(Patient patient) {
        return patientService.addPatient(patient) ? "SUCCESS" : "FAILD";
    }

    @PostMapping("/updatePatient")
    public String updatePatient(Patient patient) {
        return patientService.updatePatient(patient) ? "SUCCESS" : "FAILD";
    }

    @GetMapping("/deletePatient/{id}")
    public String deletePatient(@PathVariable("id") Integer id) {
        return patientService.deletePatient(id) ? "SUCCESS" : "FAILD";
    }

    @RequestMapping("/test")
    public String test(@RequestParam Map<String,String> map) {
        System.out.println("test.map = " + map);
        return "test";
    }

}
